//
//  LSAttentionTableViewCell.m
//  KuaiYi
//
//  Created by 黄金林 on 2016/11/13.
//  Copyright © 2016年 HeiMa. All rights reserved.
//

#import "LSAttentionTableViewCell.h"
#import <Masonry.h>
@implementation LSAttentionTableViewCell

- (void)awakeFromNib {
    [super awakeFromNib];
    // Initialization code
}
-(instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier{
    if (self = [super initWithStyle:style reuseIdentifier:reuseIdentifier]) {
        [self setupUI];
    }
    return self;
}
-(void)setupUI{
    UIImageView *imgView = [[UIImageView alloc]init];
    imgView.image = [UIImage imageNamed:@"AttentionDoctor/doctor_defaultphoto_male"];
    [imgView sizeToFit];
    [self.contentView addSubview:imgView];
    //名字label
    UILabel *nameLB = [[UILabel alloc]init];
    [nameLB sizeToFit];
    [nameLB setText:@"姜伟"];
    nameLB.font = [UIFont systemFontOfSize:13];
    [self.contentView addSubview:nameLB];
    //职位label
    UILabel *postLB = [[UILabel alloc]init];
    [postLB sizeToFit];
    [postLB setText:@"心理医生"];
    postLB.font = [UIFont systemFontOfSize:13];
    [self.contentView addSubview:postLB];
    UILabel *hospitalLB = [[UILabel alloc]init];
    [hospitalLB sizeToFit];
    [hospitalLB setText:@"北京协和医院"];
    [hospitalLB setFont:[UIFont systemFontOfSize:13]];
    [self.contentView addSubview:hospitalLB];
    UIButton *btn = [[UIButton alloc]init];
    self.accessoryView = btn;
    [self.contentView addSubview:btn];
    //预约按钮
    UIButton *appointmentBtn = [[UIButton alloc]init];
    [appointmentBtn setImage:[UIImage imageNamed:@"AttentionDoctor/knife"] forState:UIControlStateNormal];
    [self.contentView addSubview:appointmentBtn];
    //预约数label
    UILabel *appointmentNumLB = [[UILabel alloc]init];
    [appointmentNumLB setText:@"0"];
    appointmentNumLB.font = [UIFont systemFontOfSize:13];
    [self.contentView addSubview:appointmentNumLB];
    UIButton *flowerBtn = [[UIButton alloc]init];
    [flowerBtn setImage:[UIImage imageNamed:@"AttentionDoctor/flower"] forState:UIControlStateNormal];
    [self.contentView addSubview:flowerBtn];
    UILabel *flowerNumLB = [[UILabel alloc]init];
    [self.contentView addSubview:flowerNumLB];
    //自动布局
    [imgView mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.top.equalTo(self.contentView).offset(5);
        make.bottom.equalTo(self.contentView).offset(-5);
        make.width.mas_equalTo(50);
        make.height.mas_offset(50);
    }];
    [nameLB mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.equalTo(self.contentView).offset(6);
        make.left.equalTo(imgView.mas_right).offset(6);
        
    }];
    [postLB mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.equalTo(nameLB);
        make.centerY.equalTo(nameLB.mas_centerY);
        make.left.equalTo(nameLB.mas_right).offset(8);
    }];
    [hospitalLB mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.equalTo(nameLB);
        make.top.equalTo(nameLB.mas_bottom).offset(4);
    }];
    [appointmentBtn mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.equalTo(hospitalLB.mas_bottom);
        make.left.equalTo(imgView.mas_right).offset(20);
        make.bottom.equalTo(self.contentView);
    }];
    [appointmentNumLB mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.equalTo(appointmentBtn.mas_right).offset(18);
        make.top.equalTo(hospitalLB.mas_bottom);
        make.centerY.equalTo(appointmentBtn);
    }];
    [flowerBtn mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.equalTo(appointmentNumLB.mas_right).offset(18);
        make.top.equalTo(hospitalLB.mas_bottom);
        make.centerY.equalTo(appointmentBtn.mas_centerY);
        make.bottom.equalTo(self.contentView);
    }];
    
}

- (void)setSelected:(BOOL)selected animated:(BOOL)animated {
    [super setSelected:selected animated:animated];

    // Configure the view for the selected state
}

@end
